<?php
namespace app\serverfile\service\file;

use app\manage\service\ApiBase;
use think\Validate;

class ApiFile extends ApiBase
{
    protected $fileLogic = 'app\serverfile\logic\File';
    protected $fileValidate = 'app\serverfile\validate\File';
    protected $i = 0;
    //上传文件
    public function upload()
    {
        if (!isset($_FILES['files']) && !isset($_FILES['file'])) {
            return auto_failure(['res' => false], '上传文件不存在');
        }
        if (!isset($_FILES['files']) && isset($_FILES['file'])) {
            $_FILES['files'] = $_FILES['file'];
        }
        $data = $this->receiveData(['type'=>'']);
        return $this->logic($this->fileLogic)->checkFile($data);
    }

    public function fileDelete()
    {
        if (empty($this->arrData)) {
            return null_data($this->arrData,"参数不能为空！");
        }
        $data = $this->receiveData(['id'=>'']);
        return $this->stepRun($data,'fileDelete','',$this->fileValidate,$this->fileLogic);
    }

    public function fileGain()
    {
        if (empty($this->arrData)) {
            return null_data($this->arrData,"参数不能为空！");
        }
        $data = $this->receiveData(['id'=>'']);
        return $this->stepRun($data,'fileGain','',$this->fileValidate,$this->fileLogic);
    }
}